package com.ruoyi.web.controller.wnjk.hospital;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.wnjk.domain.po.WnjkPatient;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.wnjk.service.IWnjkPatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 就诊人信息Controller
 *
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/hospital/patient")
public class WnjkPatientController extends BaseController
{
    @Autowired
    private IWnjkPatientService wnjkPatientService;



    /**
     * 查询就诊人信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:patient:list')")
    @GetMapping("/list")
    public TableDataInfo list(WnjkPatient wnjkPatient)
    {
        startPage();
        List<WnjkPatient> list = wnjkPatientService.selectWnjkPatientList(wnjkPatient);
        return getDataTable(list);
    }

    /**
     * 导出就诊人信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:patient:export')")
    @Log(title = "就诊人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WnjkPatient wnjkPatient)
    {
        List<WnjkPatient> list = wnjkPatientService.selectWnjkPatientList(wnjkPatient);
        ExcelUtil<WnjkPatient> util = new ExcelUtil<WnjkPatient>(WnjkPatient.class);
        util.exportExcel(response, list, "就诊人信息数据");
    }

    /**
     * 获取就诊人信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:patient:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wnjkPatientService.selectWnjkPatientById(id));
    }

    /**
     * 新增就诊人信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:patient:add')")
    @Log(title = "就诊人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WnjkPatient wnjkPatient)
    {
        return toAjax(wnjkPatientService.insertWnjkPatient(wnjkPatient));
    }

    /**
     * 修改就诊人信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:patient:edit')")
    @Log(title = "就诊人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WnjkPatient wnjkPatient)
    {
        return toAjax(wnjkPatientService.updateWnjkPatient(wnjkPatient));
    }

    /**
     * 删除就诊人信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:patient:remove')")
    @Log(title = "就诊人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wnjkPatientService.deleteWnjkPatientByIds(ids));
    }
}
